package src;

import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;

class Latex{
	
	public Latex(){}
	
	public static String crearArbol(String raiz, String ... hijos){
		String arbol = "[."+raiz;
		for(String h: hijos){
			arbol += " "+h;
		}
		arbol+= " ]";
		return arbol;		
	}
	
	public static void toLatex(String arbol) throws FileNotFoundException, IOException {
		
		FileWriter log = new FileWriter(Config.FICHERO_LATEX);
		
		// Clase del documento y opciones generales
		log.write("\\documentclass[a0,landscale]{a0poster}\n");

		// Paquetes utilizados
		log.write("\\usepackage[utf8]{inputenc}\n");
		log.write("\\usepackage{amsmath}\n");		
		log.write("\\usepackage{amsfonts}\n");
		log.write("\\usepackage{amssymb}\n");
		log.write("\\usepackage{qtree}\n");

		log.write("\\title{Modo Debug Visual en \\LaTeX{}}\n");
		log.write("\\author{Xavier Gallofre Nieva}\n");
		log.write("\\begin{document}\n");
		log.write("\\maketitle"+"\n");

		log.write("\\Tree "+arbol+"\n");
		log.write("\\end{document}\n");
		
		log.close();
		//Runtime.getRuntime().exec ("cmd pdflatex -synctex=1 -interaction=nonstopmode arbol_ejecucion.tex");
	}

}

